<!--
 * @Author: sunli
 * @Date: 2024-04-26 15:07:17
 * @LastEditors: sunli
 * @LastEditTime: 2024-05-14 10:25:13
 * @FilePath: /debug/test_html/网络异常.html
 * @Description: 
-->
<!--
 * @Author: sunli
 * @Date: 2024-02-21 19:17:33
 * @LastEditors: sunli
 * @LastEditTime: 2024-05-14 09:42:06
 * @FilePath: /debug/test_html/网络异常.html
 * @Description: 
-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>test-1</title>
  <script src="./lib/networkListener.js"></script>
  <script src="./lib/debugger.js"></script>
  <script type="module">
    window.debugger('1708500391686-test1')
  </script>
  <script src="https://cdn.bootcdn.net/ajax/libs/axios/1.5.0/axios.js"></script>
  <script>


// https://zhuanlan.zhihu.com/p/557532887
  </script>
</head>
<body>
  <h2>网络——测试页</h2>

  <div>
    <span>HTTP请求-ajax</span>
    <button onclick="addErr('ajax')">测试</button>
  </div>
  <div>
    <span>HTTP请求-fetch</span>
    <button onclick="addErr('fetch')">测试</button>
  </div>
  <div>
    <span>HTTP请求-axios</span>
    <button onclick="addErr('axios')">测试</button>
  </div>
  <div>
    <span>behaviour</span>
    <button onclick="console.log(window.behaviour)">查看behaviour</button>
  </div>
  <script>
    const addErr = (type) => {
      if (type === 'ajax') {
        const xhr = new XMLHttpRequest()
        xhr.open('GET', 'https://jsonplaceholder.typicode.com/todos/1')
        xhr.send('123')
      }
      if (type === 'fetch') {
        fetch('https://jsonplaceholder.typicode.com/todos/1')
					.then(res => {
						console.log(res);
					})
      }
      if (type === 'axios') {
        axios('https://jsonplaceholder.typicode.com/todos/1')
					.then(res => {
						console.log(res);
					})
      }
    }
  </script>
</body>
</html>